% Campbell_Shiller_UK plot
clearvars -except Globaloption option

if exist('Globaloption', 'var') == 0
    Globaloption.savefig = 1;
end

%% Benchmark
startdatenum = 1729;
enddatenum = 1946;

% benchmark with cy = 0 before 1794
option.robust = 4;
filename = ['MAT/cy_UK_case', num2str(option.robust)];
load(filename);
ttime = [1729:1:1946];
output_rp = 0.03;
f = figure;
f.Position = [1000 918 560 300];
ylimit = [1, 2];
plot_CI(startdatenum:enddatenum, s, std_coeff, gdebt, upper, ylimit)
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print(['../../results/figures_main/UK/pre1946/cs_UK_cy_partial_', num2str(output_rp * 1000)], '-dpdf', '-fillpage');
end

%% plot robustness (zero cy before 1794)
% alternative cy and with debt in var
option.robust = 4;
filename = ['MAT/cy_UK_case', num2str(option.robust)];
load (filename);
ttime = [1729:1:1946];

f = figure;
f.Position = [1000 918 560 300];
hg = plot(ttime, gdebt(2:end), 'Color', 'blue', 'LineWidth', 2.5); hold on;
hd = plot(ttime, s, 'Color', 'red', 'LineWidth', 2.5); hold on;
axis([min(ttime) max(ttime) 0 2])

option.robust = 6;
filename = ['MAT/cy_UK_case', num2str(option.robust)];
load (filename);
he = plot(ttime, s, 'LineStyle', '-.', 'LineWidth', 2.5); hold on;

load MAT/debtinVAR_cy_partial_UK_pre1945.mat
hud = plot(ttime, s, 'LineWidth', 2.5); hold on;
axis([min(ttime) max(ttime) -1 2])
grid on

hleglines = [hg hd he hud];
legend(hleglines, 'Debt/GDP', 'Benchmark', 'Const. Conv. Yield', 'Debt-in-VAR with CY', 'location', 'southwest')
grid on
xlabel('Year')
ylabel('PV(Surplus+CY)/GDP')
set(gca, 'Layer', 'top', 'FontSize', 9)
set(gca, 'FontName', 'Times New Roman')
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];

if Globaloption.savefig == 1
    print('../../results/figures_main/UK/pre1946/cs_UK_cy_partial_robust', '-dpdf', '-fillpage')
end

% 0.02 output risk premia
f = figure;
f.Position = [1000 918 560 300];
ttime = [1729:1:1946];
option.robust = 4;
filename = ['MAT/cy_UK_case', num2str(option.robust)];
load (filename);
hg = plot(ttime, gdebt(2:end), 'Color', 'blue', 'LineWidth', 2.5); hold on;
hc = plot(ttime, s, 'Color', 'r', 'LineWidth', 2.5); hold on;
option.robust = 5;
filename = ['MAT/cy_UK_case', num2str(option.robust)];
load (filename);
hud = plot(ttime, s, 'LineWidth', 2.5); hold on;
hleglines = [hg hc hud];
legend(hleglines, 'Debt/GDP', 'Benchmark', 'rp^Y = 2%', 'location', 'southwest')
grid on
set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];
axis([min(ttime) max(ttime) -0.5 2])
xlabel('Year')
ylabel('PV(Surplus)/GDP')
set(gca, 'Layer', 'top', 'FontSize', 9)
set(gca, 'FontName', 'Times New Roman')

if Globaloption.savefig == 1
    print(['../../results/figures_main/UK/pre1946/cs_UK_30_20_partial'], '-dpdf', '-fillpage');
end

